public class Testfinally {
    public static void main(String[] args) {
        try{
            /*int[] array = null;
            System.out.println(array[10]);*/
            int[] array = {1,2,3};
            System.out.println(array[2]);
            System.out.println("after");
        }catch (ArithmeticException arithmeticException){
            arithmeticException.printStackTrace();
            System.out.println("捕捉到了ArithmeticException异常");
        }catch (NullPointerException nullPointerException){
            nullPointerException.printStackTrace();
            System.out.println("捕捉到了NullPointerException异常");
        }finally {
            System.out.println("我是finally");
            //测试1：当异常存在时，finally可被执行
            //测试2：当异常不存在时，finally可被执行
        }
    }

}
